package tcp_ip;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;

public class InetAddressExample {
	public static void main(String[] args) {
		try {
			Enumeration<NetworkInterface> interfaceList = NetworkInterface.getNetworkInterfaces();
			if(interfaceList == null) {
				
			} else {
				while(interfaceList.hasMoreElements()) {
					NetworkInterface iface = interfaceList.nextElement();
					System.out.println("Interface " + iface.getName() + ": ");
					Enumeration<InetAddress> addrList = iface.getInetAddresses();
					if(addrList != null) {
						while (addrList.hasMoreElements()) {
							InetAddress addr = addrList.nextElement();
							System.out.println("host: " + addr.getHostAddress());
						}
					}
				}
			}
			
		} catch (SocketException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
